﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Collections;

public partial class XSSJ_QLMXBack : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    string sID = CommonUse.GetID("id");
    string sMode = CommonUse.GetID("mode");
    string sSql = @"select (a.ysql-isnull(sum(b.bqql),0)) cy from sjlr_cbsj a,sjlr_bqql b where a.cbsjid=b.cbsjid and a.cbsjid=@0
group by a.ysql";
    SqlParameter[] cmdParams = { new SqlParameter("@0", SqlDbType.VarChar, 20) };
    cmdParams[0].Value = sID;
    SqlDataReader dr = DbHelperSQL.ExecuteReader(sSql, cmdParams);
    string sCY = "";
    if (dr.Read())
    {
      sCY = dr["cy"].ToString();
    }
    dr.Close();
    if (sCY.Equals("0"))
    {
    }
    else
    {
      List<CommandInfo> cis = new List<CommandInfo>();

      cis.Add(CommonUse.DeleteCI("SJLR_CBSJ", "cbsjid", CommonUse.GetID()));
      cis.Add(CommonUse.DeleteCI("SJLR_bqql", "cbsjid", CommonUse.GetID()));

      if (DbHelperSQL.ExecuteSqlTran(cis) > 0)
      {

      }
    }
    if (sMode == "1")
    {
      Server.Transfer("XSSJKHList.aspx");
    }
    else
    {
      Server.Transfer("XSSJList.aspx");
    }
  }
}
